import { defineStore } from "pinia";
import { IndexState, IndexGetters, IndexActions } from "@/types/index.type"
// 在此约束类型不管编写或使用都可有较好的提示
export const useIndexStore = defineStore<
  string,
  IndexState,
  IndexGetters,
  IndexActions
>("IndexId", {
  state: () => ({
    count: 10,
    user: {
      age: 18,
      name: "windy",
    },
  }),
  persist: true, // 是否持久化
  getters: {
    doubleCount: (state) => state.count * 2,
    username: (state) => state.user.name,
  },
  actions: {
    setCount(count: number) {
      this.count = count;
    },
  },
});
